package com.sailing.core.demo.enmumap;

import java.util.Random;

public class RoShamBo {
	 public static <T extends Competitor<T>> void match(T a, T b) {  
     System.out.println(a + " vs. " + b + ": " + a.compete(b));  
 }  

 public static  <T extends Enum<T> & Competitor<T>> void play(  
         Class<T> rsbClass, int size) {  
     for (int i = 0; i < size; i++)  
         match(Enums.random(rsbClass), Enums.random(rsbClass));  
 }  
 
 static class Enums{
	 private static Random rand = new Random(47); 
	 static RoShamBo5 random(Class rsbClass ){
		 switch (rand.nextInt(3)) {  
     default:  
     case 0:  
         return RoShamBo5.PAPER;  
     case 1:  
         return RoShamBo5.ROCK;  
     case 2:  
         return RoShamBo5.SCISSORS;  
     }  
	 }
 }
}
